package com.example.deokr.myapplication;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.google.android.gcm.server.Message;
import com.google.android.gcm.server.MulticastResult;
import com.google.android.gcm.server.Result;
import com.google.android.gcm.server.Sender;

public class GCMServerSide {
    public static void sendMessage() throws IOException {

        Sender sender = new Sender("AIzaSyCzoEbCwGnemPGjgzCie5pGX0ERsfuppQA");

        String regId = "APA91bGj5a5Hukm_0HxWvRnjTESXmCa6IyL-Oex45VFTuRfXCywIuA_VlxejJ5xvPc8LXehWAnBgpBJe2r4J0XZQom-MpQ_FKfRq46HdlR1FZRmzPwS6LWX_6nmHhZTolpPi4WFklu4sJzaC2qpooWS8Rrlvqlf1i7fVICB2FnV_SB5n6uKgh_U";

        Message message = new Message.Builder().addData("msg", "Fuck!!!!").build();
        List<String> list = new ArrayList<String>();
        list.add(regId);
        MulticastResult multiResult = sender.send(message, list, 5);

        if (multiResult != null) {
            List<Result> resultList = multiResult.getResults();
            for (Result result : resultList) {
                System.out.println(result.getMessageId());
            }
        }
    }

    public static void main(String[] args) throws Exception {
        GCMServerSide s = new GCMServerSide();
        s.sendMessage();
    }
}
